@extends('Home.User.Common.layout')
@section('title')
    所有职位_职位管理
@endsection
@section('content')
    <!--  content  -->
    <main class="common_content">
        <div class="container">
            <div class="ct_main">
                @include('Home.User.Position.position_menu')
                <ul class="nav-items1 nav-items2" id="tab-content2">
                    <!--所有职位-->
                    <li class="basic-sets active">
                        <form class="selector-head" method="post" action="{{route('position_all')}}">
                            @csrf
                            <h2>所有职位  <span style="font-size:12px">（招聘状态closed职位不做展示，如需展示请修改招聘状态为招聘中）</span></h2>
                            <div class="rt">
                                <div class="layui-input-inline layui-form" style="width: 150px;margin-right: 2px; margin-top: -1px;">
                                        <select name="client_id" lay-search id="client_id">
                                            <option value="">选择所属公司</option>
                                            @foreach($client as $item)
                                                <option value="{{$item->id}}"  @if($act['client_id'] == $item->id) selected  @endif >{{$item->chinese_name}}</option>
                                            @endforeach
                                        </select>
                                </div>
                                <div class="layui-input-inline layui-form" style="width: 150px;margin-right: 2px;vertical-align: unset;">
                                    <input type="text" name="title"  value="{{$act['title']}}"  placeholder="请输入职位名称" autocomplete="off" class="layui-input">
                                </div>
                                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="formSub"><i class="icon icon-search"></i></button>

                                <a href="javascript:;" class="add-new-btn add-client" onclick="open_button('{{route('position_add')}}','新增职位')" title="新增职位"><i class="icon icon-xinzen"></i></a>
                                <a href="javascript:location.replace(location.href);" class="refresh-btn" title="刷新"><i class="icon icon-shuaxin"></i></a>
                            </div>
                        </form>
                        <div class="layui-form basic-sets-ul">
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th width="50">编号</th>
                                    <th width="70">招聘时间</th>
                                    <th width="50">团队</th>
                                    <th width="50">归属</th>
                                    <th width="70">紧急程度</th>
                                    <th width="70">所属公司</th>
                                    <th width="130">职位名称</th>
                                    <th width="70">工作地点</th>
                                    <th width="70">薪资范围</th>
                                    {{--
                                                                        <th>职位类别</th>
                                    --}}
                                    <th width="70">HC</th>
                                    <th width="70">推荐CV</th>
                                    <th width="70">需求状态</th>
                                    <th width="70">悬赏金</th>
                                    <th style="width: 70px;">推荐简历</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr>
                                        <td data-label="编号" title="{{$item->id}}"> {{$item->id}} </td>
                                        <td data-label="招聘时间" title="{{$item->time}}"> {{$item->time}} </td>
                                        <td data-label="团队" title="{{$item->team_username}}"> {{$item->team_username}} </td>
                                        <td data-label="归属" title="{{$item->assign_username}}"> {{$item->assign_username}} </td>
                                        <td data-label="紧急程度" title="{{$item->emergency_name}}"> {{$item->emergency_name}} </td>
                                        <td data-label="所属公司" title="{{$item->client_name}}"> {{$item->client_name}} </td>
                                        <td data-label="职位名称" title="{{$item->title}}"> {{$item->title}} </td>
                                        <td data-label="工作地点" title="{{$item->region_name}}"> {{$item->region_name}} </td>
                                        <td data-label="薪资范围" title="{{$item->range_name}}"> {{$item->range_name}} </td>
{{--
                                        <td data-label="职位类别" title="{{$item->category_name}}"> {{$item->category_name}} </td>
--}}
                                        <td data-label="HC" title="{{$item->hc}}"> {{$item->hc}} </td>
                                        <td data-label="推荐CV" title="{{$item->cv}}"> {{$item->cv}} </td>
                                        <td data-label="需求状态" title="{{$item->state_name}}"> {{$item->state_name}} </td>
                                        <td data-label="悬赏金" title="{{$item->reward}}"> {{$item->reward}} </td>
                                        <td data-label="操作" class="tac layui-row layui-col-space10">
                                            <a href="javascript:;" class="edit-btn edit-client" onclick="open_button('{{route('position_edit',$item->id)}}','查看/编辑职位')" title="查看/编辑职位"><i class="layui-icon">&#xe642;</i></a>
                                            @if (Auth::user()->hasAnyRole(['admin']))
                                                <a href="javascript:;" class="edit-btn add-schedule" onclick="del('{{route('position_del',$item->id)}}')" title="删除"><i class="layui-icon">&#xe640;</i></a>
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <!-- 分页 s -->
                            @if($num>1)
                                <div class="news-pager">
                                    <ul class="pagination" id="page">
                                    </ul>
                                    <div class="pageJump">
                                        <span>跳转到</span>
                                        <input type="text"/>
                                        <span>页</span>
                                        <button type="button" class="button">确定</button>
                                    </div>
                                </div>
                            @endif
                            <!-- 分页 e -->
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </main>
@endsection

@section('footer')
    <script>
        /*删除*/
        function del(url) {
            layer.confirm("你确定要删除吗？此操作不能撤销！", {icon: 3, title:'提示'},
                    function(index){//确定回调
                        $.ajax({
                            type: 'get',
                            url: url,
                            dataType: 'json',
                            success: function(data){
                                if(data.code){
                                    window.location.reload();
                                    layer.close(index);
                                }else{
                                    layer.msg(data.msg,{icon: 5,time:1000});
                                }
                            },
                            error:function() {
                                layer.msg('服务器错误!',{icon: 5,time:1000});
                            }
                        });
                    },function (index) {//取消回调
                        layer.close(index);
                    }
            );
        }
        /***  分页 JS  ***/


        Page({
            num: '{{$num}}',		//页码数
            startnum: '{{$page}}',				//指定页码
            elem:$('#page'),		//指定的元素
            callback:function(n){	//回调函数
                can='title='+$("input[name='title']").val()+'&client_id='+$("#client_id").find("option:selected").val();
                if($("input[name='title']").val() || $("#client_id").find("option:selected").val()){

                    if($("input[name='title']").val()==''){
                        can='client_id='+$("#client_id").find("option:selected").val();
                    }
                    if($("#client_id").find("option:selected").val()==''){
                        can='title='+$("input[name='title']").val();
                    }
                    window.location.href = '{{route('position_all')}}?page='+n+'&'+can;
                    return false;
                }

                window.location.href = '{{route('position_all')}}?page='+n;

            }
        });
    </script>
@endsection